<template >
  <el-container class="management">
    <el-aside width="150px">
      <div class="logo">莆田头条</div>
      <el-menu
        class="el-menu-vertical-demo"
        background-color="black"
        text-color="#888"
        active-text-color="#ffd04b"
        :default-active="$route.path"
      >
        <div class="essay">文章管理</div>
        <el-menu-item index="/article">
          <span slot="title" @click="article('/article')">文章列表</span>
        </el-menu-item>

        <el-menu-item index="/publish">
          <span slot="title" @click="publish('/publish')">发布文章</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <div class="nav">
          <div class="navImg">
            <img
              :src="$axios.defaults.baseURL+data.head_img"
              class="headerAvatar"
              v-if="data.head_img"
            />
            <img src="../assets/微信图片_202007021640292.jpg" class="headerAvatar" />
            {{data.nickname}}
          </div>
          <div class="enter" @click="enter">退出</div>
        </div>
      </el-header>
      <el-main>
        <breadcrumb />
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import breadcrumb from "../views/breadcrumb";
export default {
  components: {
    breadcrumb
  },
  data() {
    return {
      data: JSON.parse(localStorage.getItem("user"))
    };
  },
  methods: {
    enter() {
      localStorage.removeItem("token");
      localStorage.removeItem("user");
      this.$router.replace("/login");
    },
    article(path) {
      if (this.$route.path != path) this.$router.push(path);
      console.log(this.$route);
    },
    publish(path) {
      if (this.$route.path != path) this.$router.push(path);
      console.log(this.$route);
    }
  },

  created() {}
};
</script>

<style lang="less" scoped>
.logo {
  height: 60px;
  line-height: 60px;
  // position: absolute;
  // top: -70px;
  // left: 30px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  padding-bottom: 20px;
}
.essay {
  font-size: 14px;
  width: 120px;
  color: #fff;
}
.nav {
  display: flex;
  font-size: 14px;
  justify-content: flex-end;
  align-items: center;
  // padding-right: 128px;
  .navImg {
    flex: 1;
    // padding-left: 280px;
    text-align: right;
    .headerAvatar {
      // padding-top: 60px;
      vertical-align: middle;
      width: 35px;
      height: 35px;
      object-fit: cover;
      border-radius: 50%;
      // margin-right: 20px;
    }
  }
  .enter {
    padding: 0 15px;
    // flex: 1;
  }
}
.management {
  width: 100%;
  top: 0;
  bottom: 0;
  position: absolute;
}
.el-header,
.el-footer {
  background-color: rgba(51, 51, 51);
  color: #888;
  text-align: center;
  line-height: 60px;
}
.el-aside {
  background-color: black;
  color: #888;
  text-align: center;
  line-height: 200px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-menu-vertical-demo {
  // padding-left: 10px;
  line-height: 20px;
  width: 150px;
  font-size: 14px;
  // color: #888;
}
.el-menu-item {
  line-height: 27px;
  height: 27px;
}
</style>

